%Author Jack Young (painstakingly commented by Ryszard)
%Checks if particles lie within a threshold radius, in order to determine
%reasonable certainty of robot location. Standard deviation is threshold of
%acceptable gatheringness.
function [closelygathered,center] = found(particles)
particles = particles(1:round(end/5),:);
meanX = mean(particles(:,1));
meanY = mean(particles(:,2));
center = [meanX,meanY];
stdX = std(particles(:,1));
stdY = std(particles(:,2));
disp('Standard Deviation:');
disp(stdX);
if (stdX < 16) & (stdY < 16)
    closelygathered = 1;
else
    closelygathered = 0;
end
    